//
//  Sqlite3Utils.h
//  dragonWorld
//
//  Created by yanglishuan on 13-9-3.
//
//

#ifndef __dragonWorld__Sqlite3Utils__
#define __dragonWorld__Sqlite3Utils__

#include <iostream>
#include <sqlite3.h>
#include "ccCArray.h"
#include "CCString.h"
#include "CCDictionary.h"
#include "CCData.h"

class Sqlite3Utils {
public:
    sqlite3 *sqlite3_db;
public:
    Sqlite3Utils(void) {};
    Sqlite3Utils(const char *path);
    ~Sqlite3Utils();
    
    int open_sqlite();
    int close_sqlite();
    
    cocos2d::CCArray* results(const char * tableName, const char * condition, const char *order,  bool asc);
    int insert(const char *tableName, cocos2d::CCDictionary *data);
    int update(const char *tableName, cocos2d::CCDictionary *data, const char * condition);
    int remove(const char *tableName, const char * condition);
private:
    cocos2d::CCString dbPath;
    cocos2d::CCArray *column_names;
    cocos2d::CCArray* readTableColumnNamesAndTypes(const char *tableName);
};

#endif /* defined(__dragonWorld__Sqlite3Utils__) */
